var app = getApp(), api = app.api, is_no_more = !1, is_loading = !1, p = 2;

Page({
    data: {
        status: 1,
        first_count: 0,
        second_count: 0,
        third_count: 0,
        list: Array,
        no_more: !1,
        ssvalue:'',
        dd:'',
        USER_INFO:{},
        manager:0
    },
    onLoad: function(t) {
        getApp().page.onLoad(this, t);
        var a = getApp().core.getStorageSync(getApp().const.SHARE_SETTING),first_count = getApp().core.getStorageSync('first_count'),second_count = getApp().core.getStorageSync('second_count');
        var USER_INFO = wx.getStorageSync('USER_INFO')
        if(t.dd){
            this.setData({
                dd:t.dd
            })
        }
        this.setData({
            share_setting: a,
            first_count:first_count,
            second_count:second_count,
            USER_INFO:USER_INFO
        }), is_no_more = is_loading = !1, p = 2, this.GetList(t.status || 1,''),this.subcompany();
    },
    ss:function(e){
        console.log(e)
        var a = this
        a.setData({
            ssvalue:e.detail.value
        })
    },
    order_list:function(e){
        console.log(e)
        var id = e.currentTarget.dataset.id
        wx.navigateTo({
          url: '/pages/share-user-order-list/share-user-order-list?id=' + id,
        })
    },
    sousuo:function(e){
        var a = this
        a.GetList(a.data.status,a.data.ssvalue)
    },
    GetList: function(t,f) {
        var a = this;
        console.log('1111111111',t)
        if(t == 10){
            var uu = getApp().api.share.subcompany
            var uudata = {
                page: 1,
                keyword:f
            }
        }else{
            var uu = getApp().api.share.get_team
            var uudata = {
                status: t,
                page: 1,
                keyword:f
            }
        }
        is_loading || (is_loading = !0, a.setData({
            status: parseInt(t || 1)
        }), getApp().core.showLoading({
            title: "正在加载",
            mask: !0
        }),getApp().request({
            url: uu,
            data:uudata,
            success: function(t) {
                wx.setStorageSync('first_count', t.data.first)
                wx.setStorageSync('second_count', t.data.second)
                a.setData({
                    first_count: t.data.first,
                    second_count: t.data.second,
                    third_count: t.data.third,
                    list: t.data.list,
                    manager:t.data.manager
                }), 0 == t.data.list.length && (is_no_more = !0, a.setData({
                    no_more: !0
                }));
            },
            complete: function() {
                getApp().core.hideLoading(), is_loading = !1;
            }
        }));
    },
    subcompany:function(e){
        var a = this
        getApp().request({
            url: getApp().api.share.subcompany,
            data:{
                page: 1,
                keyword:f
            },
            success: function(t) {
                a.setData({
                    manager:t.data.manager
                })
            },
        })
    },
    onReachBottom: function() {
        is_no_more || this.loadData();
    },
    loadData: function() {
        if (!is_loading) {
            is_loading = !0;
            var a = this;
            if(a.data.status == 10){
                var uu = getApp().api.share.subcompany
                var uudata = {
                    page: p
                }
            }else{
                var uu = getApp().api.share.get_team
                var uudata = {
                    status: a.data.status,
                    page: p
                }
            }
            getApp().core.showLoading({
                title: "正在加载",
                mask: !0
            }), getApp().request({
                url: uu,
                data:uudata,
                success: function(t) {
                    wx.setStorageSync('first_count', t.data.first)
                    wx.setStorageSync('second_count', t.data.second)
                    a.setData({
                        first_count: t.data.first,
                        second_count: t.data.second,
                        third_count: t.data.third,
                        list: a.data.list.concat(t.data.list)
                    }), 0 == t.data.list.length && (is_no_more = !0, a.setData({
                        no_more: !0
                    }));
                },
                complete: function() {
                    getApp().core.hideLoading(), is_loading = !1, p++;
                }
            });
        }
    }
});